<template>
  <!--begin::List Widget 1-->
  <div class="card card-custom card-stretch gutter-b">
    <!--begin::Header-->
    <div class="card-header border-0">
      <h3 class="card-title font-weight-bolder text-dark">知识库</h3>
      <div class="card-toolbar">
      </div>
    </div>
    <!--end::Header-->
    <!--begin::Body-->
    <div class="card-body pt-2">
      <template v-for="(item, i) in list">
        <!--begin::Item-->
        <div class="d-flex align-items-center mb-10" v-bind:key="i">
          <!--begin::Symbol-->
          <!-- <div class="symbol symbol-25 mr-5" v-bind:class="`symbol-light-${item.style}`" >
            <span class="symbol-label">
              <span class="svg-icon svg-icon-lg" v-bind:class="`svg-icon-${item.style}`" >
                <inline-svg :src="item.svg"></inline-svg>
              </span>
            </span>
          </div> -->
          <!--end::Symbol-->
          <!--begin::Text-->
          <div class="d-flex flex-column font-weight-bold">
            <a href="#" class="text-dark text-hover-primary mb-1 font-size-lg">
              {{ item.title }}
            </a>
            <span class="text-muted">
              {{ item.createBy }} {{ item.createTime }}
            </span>
          </div>
          <!--end::Text-->
        </div>
        <!--end::Item-->
      </template>
    </div>
    <!--end::Body-->
  </div>
  <!--end: List Widget 1-->
</template>

<script>
import { mapGetters } from "vuex";
import apiUtil from "@/core/util/apiUtil.js";  
export default {
  name: "widget-1",
  data() {
    return {
      searchForm: { },
      list: [],
      sels: [], //当前选框选中的值
      pageNo: 1,      // 默认当前是第一页
      pageSize: 5,    // 当前每页的数据是5条
      totalCount: 0   // 总数默认为0
    };
  },
  mounted() {
      this.initList();  
  },
  methods: {
    initList() {
          var params = {};
          params.usePageNo = true;//采用第几页进行分页（兼容）
          params.pageSize = this.pageSize;//页面显示记录条数，在页面显示每页显示多少项的时候
          params.pageNo = this.pageNo;//开始的记录序号   
          params.searchJson = JSON.stringify(this.searchForm);//为form元素     
          apiUtil.queryPage(process.env.VUE_APP_SYS_API + "sysKnowledge/list", params).then(({ data }) => {
              this.list = data.data;//给结果集赋值
              for(let i in this.list){
                  if(this.list[i].type == 0){
                    this.list[i].style = "danger"
                    this.list[i].svg =  "media/svg/icons/Communication/Group-chat.svg"
                  }else{
                    this.list[i].style = "waring"
                    this.list[i].svg =  "media/svg/icons/General/Notification2.svg"
                  }
              }
              this.totalCount = data.total;// 获取当前数据的总数    
          });
      }
  },
  components: {
    
  }
};
</script>
